package com.caigp.cookbook2.fragment;

import android.content.Intent;
import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.caigp.cookbook2.BuildConfig;
import com.caigp.cookbook2.R;
import com.caigp.cookbook2.activity.FavoriteActivity;
import com.tencent.bugly.beta.Beta;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MoreFragment extends Fragment implements View.OnClickListener {

    private View view;

    @BindView(R.id.version_name)
    TextView versionName;

    @BindView(R.id.my_favorite)
    LinearLayout myFavorite;

    @BindView(R.id.check_update)
    LinearLayout checkUpdate;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_more, container, false);
        ButterKnife.bind(this, view);
        versionName.setText(BuildConfig.VERSION_NAME);
        myFavorite.setOnClickListener(this);
        checkUpdate.setOnClickListener(this);
        return view;
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.my_favorite) {
            Intent intent = new Intent(getContext(), FavoriteActivity.class);
            startActivity(intent);
        } else if (id == R.id.check_update) {
            Beta.checkUpgrade(true,false);
        }
    }
}
